// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'
import API from './API'

// ============================== 导出异步调用 ============================== //

export default {
  // —————————————————————————————— 信息 —————————————————————————————— //

  async remoteInfo({ state: { infoParam } }) {
    const obj = await API.getInfo(infoParam)
    return transInfo(obj)
  },
}

// ============================== 转换方法 ============================== //

const transInfo = (obj) => {
  const typeList = obj.infoList || []
  const plan = typeList.find((item) => item.name === 'plan') || {}
  const point = typeList.find((item) => item.name === 'point') || {}

  return {
    plan: CORE.mul(plan.value, 100),
    point: CORE.mul(point.value, 100),
  }
}
